<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script type="text/javascript">
        window.onload=function()
        {
            //0. Number.EPSILON是JavaScript表示的最小精度，该属性值接近于2.2204460492503130808472633361816E-16
            console.log(Number.EPSILON);
            console.log(0.1+0.2);//该算式的结果不等于0.3，也就是跟我们认知的常理不同
            //此问题可以借助Number.EPSILON来解决
            function equal(a,b){
                if(Math.abs(a-b)<Number.EPSILON)
                {
                    return true;
                }
                else
                {
                    return false;
                }
            }
            console.log(equal(0.1+0.2,0.3))

            //1.二进制和八进制
            let b=0b1010;//二进制 0b开头
            let o=0o777;//八进制 0o开头
            let d=100;//十进制
            let x=0xff;//十六进制 0x开头
            console.log(b);
            console.log(o);
            console.log(d);
            console.log(x);

            //2.Number.isFinite 检测一个数值是否为有限数
            console.log(Number.isFinite(100));
            console.log(Number.isFinite(100/0));
            console.log(Number.isFinite(Infinity));

            //3.Number.isNaN 检测一个数值是否为NaN
            console.log(Number.isNaN(123));

            //4.Number.parseInt Number.parseFloat字符串转为整数
            console.log(Number.parseInt("5415313LOVE"));
            console.log(Number.parseInt("54153T13LOVE"));
            console.log(Number.parseFloat("3.15154653LOVE"));
            console.log(Number.parseFloat("3.1515u4653LOVE"));

            //5.Number.isTnteger
            console.log(Number.isInteger(5));
            console.log(Number.isInteger(2.5));
            console.log(Number.isInteger(5.0));

            //6.Math.trunc 将数字的小数部分抹掉
            console.log(Math.trunc(5));
            console.log(Math.trunc(2.5));
            console.log(Math.trunc(5.0));

            //7.Math.sign 判断一个数到底是正数负数还是零 如果是正数 就输出1 如果是负数 就输出-1 如果是0 就输出0
            console.log(Math.sign(100));
            console.log(Math.sign(-100));
            console.log(Math.sign(0));
        };
    </script>
</head>
<body>
    
</body>
</html>